<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui">

<h:head></h:head>
<body>
	<h:panelGroup id="panelGroupCliente" layout="block">
		<!-- Listar Cliente -->
		<p:panel id="painelListarCliente" widgetVar="painelListarCliente"
			visible="true" closable="true" closeSpeed="0" style="border: none">
			<h:form id="formListarCliente">
				<p:commandLink update=":formIncluirCliente"
					action="#{clienteBean.limparCliente}"
					oncomplete="PF('painelListarCliente').close(); PF('painelIncluirCliente').show();">
					<h:outputText value="Incluir Cliente" />
				</p:commandLink>
				<p:dataTable style="width: 50%;" value="#{clienteBean.clientes}"
					var="cliente" emptyMessage="" id="tableCli" paginator="true"
					rows="7"
					paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
					rowsPerPageTemplate="7,14,21">

					<p:column>
						<f:facet name="header">
							<h:outputText value="CPF" />
						</f:facet>
						<h:outputText value="#{cliente.cpf}" />
					</p:column>
					<p:column>
						<f:facet name="header">
							<h:outputText value="Login" />
						</f:facet>
						<h:outputText value="#{cliente.login}" />
					</p:column>
					<p:column>
						<p:commandButton value="Consultar" update=":formConsultarCliente"
							oncomplete="PF('painelConsultarCliente').show(); PF('painelListarCliente').close();">
							<f:setPropertyActionListener target="#{clienteBean.cliente}"
								value="#{cliente}"></f:setPropertyActionListener>
						</p:commandButton>
					</p:column>
					<p:column>
						<p:commandButton value="Alterar" update=":formAlterarCliente"
							oncomplete="PF('painelAlterarCliente').show(); PF('painelListarCliente').close();">
							<f:setPropertyActionListener target="#{clienteBean.cliente}"
								value="#{cliente}"></f:setPropertyActionListener>
						</p:commandButton>
					</p:column>
					<p:column>
						<p:commandButton value="Excluir"
							action="#{clienteBean.excluirCliente}"
							update=":formListarCliente">
							<f:setPropertyActionListener target="#{clienteBean.cliente}"
								value="#{cliente}"></f:setPropertyActionListener>
							<p:confirm header=""
								message="Tem certeza que deseja efetuar esta exclusão ?"
								icon="ui-icon-alert" />
						</p:commandButton>
					</p:column>
				</p:dataTable>
			</h:form>
		</p:panel>

		<!-- Incluir Cliente -->
		<p:panel id="painelIncluirCliente" widgetVar="painelIncluirCliente"
			visible="false" closable="true" closeSpeed="0" style="border: none">
			<h:form id="formIncluirCliente">
				<p:panel style="width: 50%;">
					<table>
						<tr>
							<td><h:outputLabel value="Nome: " /></td>
							<td><p:inputText id="nomeCliIncl"
									value="#{clienteBean.cliente.nome}" label="Nome" /></td>
						</tr>
						<tr>
							<td><h:outputLabel value="Data de Nascimento: " /></td>
							<td><p:calendar id="dataNascCliIncl"
									value="#{clienteBean.dataNasc}" pattern="dd/MM/yyyy"
									locale="pt" showOn="button" /></td>
						</tr>
						<tr>
							<td><h:outputLabel value="Sexo: " /></td>
							<td><h:selectOneMenu id="sexoCliIncl"
									value="#{clienteBean.cliente.sexo}">
									<f:selectItem itemLabel="Selecione" itemValue="" />
									<f:selectItem itemLabel="Masculino" itemValue="M" />
									<f:selectItem itemLabel="Feminino" itemValue="F" />
								</h:selectOneMenu></td>
						</tr>
						<tr>
							<td><h:outputLabel value="Login: " /></td>
							<td><p:inputText id="loginCliIncl"
									value="#{clienteBean.cliente.login}" label="Login" /></td>
						</tr>
						<tr>
							<td><h:outputLabel value="CPF: " /></td>
							<td><p:inputMask id="cpfCliIncl"
									value="#{clienteBean.cliente.cpf}" label="cpf" mask="999.999.999-99" /></td>
						</tr>
						<tr>
							<td><h:outputLabel value="Telefone: " /></td>
							<td><p:inputText id="telefoneCliIncl"
									value="#{clienteBean.cliente.telefone}" label="telefone" /></td>
						</tr>
						<tr>
							<td><h:outputLabel value="Endereço: " /></td>
							<td><p:inputText id="enderecoCliIncl"
									value="#{clienteBean.cliente.endereco}" label="endereco" /></td>
						</tr>
						<tr>
							<td><h:outputLabel value="Estado: " /></td>
							<td><h:selectOneMenu id="estadoCliIncl"
									value="#{clienteBean.cliente.estado}">
									<f:selectItem itemLabel="Selecione" itemValue="" />
									<f:selectItem itemLabel="Acre" itemValue="AC" />
									<f:selectItem itemLabel="Alagoas" itemValue="AL" />
									<f:selectItem itemLabel="Amapá" itemValue="AP" />
									<f:selectItem itemLabel="Amazonas" itemValue="AM" />
									<f:selectItem itemLabel="Bahia" itemValue="BA" />
									<f:selectItem itemLabel="Ceará" itemValue="CE" />
									<f:selectItem itemLabel="Distrito Federal" itemValue="DF" />
									<f:selectItem itemLabel="Espirito Santo" itemValue="ES" />
									<f:selectItem itemLabel="Goiás" itemValue="GO" />
									<f:selectItem itemLabel="Maranhão" itemValue="MA" />
									<f:selectItem itemLabel="Mato Grosso" itemValue="MT" />
									<f:selectItem itemLabel="Mato Grosso do Sul" itemValue="MS" />
									<f:selectItem itemLabel="Minas Gerais" itemValue="MG" />
									<f:selectItem itemLabel="Pará" itemValue="PA" />
									<f:selectItem itemLabel="Paraiba" itemValue="PB" />
									<f:selectItem itemLabel="Paraná" itemValue="PR" />
									<f:selectItem itemLabel="Pernambuco" itemValue="PE" />
									<f:selectItem itemLabel="Piauí" itemValue="PI" />
									<f:selectItem itemLabel="Rio de Janeiro" itemValue="RJ" />
									<f:selectItem itemLabel="Rio Grande do Norte" itemValue="RN" />
									<f:selectItem itemLabel="Rio Grande do Sul" itemValue="RS" />
									<f:selectItem itemLabel="Rondônia" itemValue="RO" />
									<f:selectItem itemLabel="Roraima" itemValue="RR" />
									<f:selectItem itemLabel="Santa Catarina" itemValue="SC" />
									<f:selectItem itemLabel="São Paulo" itemValue="SP" />
									<f:selectItem itemLabel="Sergipe" itemValue="SE" />
									<f:selectItem itemLabel="Tocantis" itemValue="TO" />
								</h:selectOneMenu></td>
						</tr>
						<tr>
							<td><h:outputLabel value="Cidade: " /></td>
							<td><p:inputText id="cidadeCliIncl"
									value="#{clienteBean.cliente.cidade}" label="cidade" /></td>
						</tr>
						<tr>
							<td><h:outputLabel value="Observação: " /></td>
							<td><p:inputTextarea rows="3" cols="25"
									id="observacaoCliIncl"
									value="#{clienteBean.cliente.observacao}" label="observacao" /></td>
						</tr>
					</table>
				</p:panel>

				<div class="posicao_botao" align="right">
					<p:commandButton value="Voltar" update=":formListarCliente"
						onclick="PF('painelIncluirCliente').close(); PF('painelListarCliente').show();"
						type="button" />
					<p:commandButton value="Enviar" id="botao"
						action="#{clienteBean.incluirCliente}" styleClass="botao"
						update=":formListarCliente"
						oncomplete="PF('painelIncluirCliente').close(); PF('painelListarCliente').show();" />
				</div>
			</h:form>
		</p:panel>

		<!-- Alterar Cliente -->
		<p:panel id="painelAlterarCliente" widgetVar="painelAlterarCliente"
			visible="false" closable="true" closeSpeed="0" style="border: none">
			<h:form id="formAlterarCliente">
				<p:panel style="width: 50%;">
					<table>
						<tr>
							<td><h:outputLabel value="Nome: " /></td>
							<td><p:inputText id="nomeCliIncl"
									value="#{clienteBean.cliente.nome}" label="Nome" /></td>
						</tr>
						<tr>
							<td><h:outputLabel value="Data de Nascimento: " /></td>
							<td><p:calendar id="dataNascCliIncl"
									value="#{clienteBean.dataNasc}" pattern="dd/MM/yyyy"
									locale="pt" showOn="button" /></td>
						</tr>
						<tr>
							<td><h:outputLabel value="Sexo: " /></td>
							<td><h:selectOneMenu id="sexoCliIncl"
									value="#{clienteBean.cliente.sexo}">
									<f:selectItem itemLabel="Selecione" itemValue="" />
									<f:selectItem itemLabel="Masculino" itemValue="M" />
									<f:selectItem itemLabel="Feminino" itemValue="F" />
								</h:selectOneMenu></td>
						</tr>
						<tr>
							<td><h:outputLabel value="Login: " /></td>
							<td><p:inputText id="loginCliIncl"
									value="#{clienteBean.cliente.login}" label="Login" /></td>
						</tr>
						<tr>
							<td><h:outputLabel value="CPF: " /></td>
							<td><p:inputText id="cpfCliIncl"
									value="#{clienteBean.cliente.cpf}" label="cpf" /></td>
						</tr>
						<tr>
							<td><h:outputLabel value="Telefone: " /></td>
							<td><p:inputText id="telefoneCliIncl"
									value="#{clienteBean.cliente.telefone}" label="telefone" /></td>
						</tr>
						<tr>
							<td><h:outputLabel value="Endereço: " /></td>
							<td><p:inputText id="enderecoCliIncl"
									value="#{clienteBean.cliente.endereco}" label="endereco" /></td>
						</tr>
						<tr>
							<td><h:outputLabel value="Estado: " /></td>
							<td><h:selectOneMenu id="estadoCliIncl"
									value="#{clienteBean.cliente.estado}">
									<f:selectItem itemLabel="Selecione" itemValue="" />
									<f:selectItem itemLabel="Acre" itemValue="AC" />
									<f:selectItem itemLabel="Alagoas" itemValue="AL" />
									<f:selectItem itemLabel="Amapá" itemValue="AP" />
									<f:selectItem itemLabel="Amazonas" itemValue="AM" />
									<f:selectItem itemLabel="Bahia" itemValue="BA" />
									<f:selectItem itemLabel="Ceará" itemValue="CE" />
									<f:selectItem itemLabel="Distrito Federal" itemValue="DF" />
									<f:selectItem itemLabel="Espirito Santo" itemValue="ES" />
									<f:selectItem itemLabel="Goiás" itemValue="GO" />
									<f:selectItem itemLabel="Maranhão" itemValue="MA" />
									<f:selectItem itemLabel="Mato Grosso" itemValue="MT" />
									<f:selectItem itemLabel="Mato Grosso do Sul" itemValue="MS" />
									<f:selectItem itemLabel="Minas Gerais" itemValue="MG" />
									<f:selectItem itemLabel="Pará" itemValue="PA" />
									<f:selectItem itemLabel="Paraiba" itemValue="PB" />
									<f:selectItem itemLabel="Paraná" itemValue="PR" />
									<f:selectItem itemLabel="Pernambuco" itemValue="PE" />
									<f:selectItem itemLabel="Piauí" itemValue="PI" />
									<f:selectItem itemLabel="Rio de Janeiro" itemValue="RJ" />
									<f:selectItem itemLabel="Rio Grande do Norte" itemValue="RN" />
									<f:selectItem itemLabel="Rio Grande do Sul" itemValue="RS" />
									<f:selectItem itemLabel="Rondônia" itemValue="RO" />
									<f:selectItem itemLabel="Roraima" itemValue="RR" />
									<f:selectItem itemLabel="Santa Catarina" itemValue="SC" />
									<f:selectItem itemLabel="São Paulo" itemValue="SP" />
									<f:selectItem itemLabel="Sergipe" itemValue="SE" />
									<f:selectItem itemLabel="Tocantis" itemValue="TO" />
								</h:selectOneMenu></td>
						</tr>
						<tr>
							<td><h:outputLabel value="Cidade: " /></td>
							<td><p:inputText id="cidadeCliIncl"
									value="#{clienteBean.cliente.cidade}" label="cidade" /></td>
						</tr>
						<tr>
							<td><h:outputLabel value="Observação: " /></td>
							<td><p:inputText id="observacaoCliIncl"
									value="#{clienteBean.cliente.observacao}" label="observacao" /></td>
						</tr>
					</table>
				</p:panel>

				<div class="posicao_botao" align="right">
					<p:commandButton value="Voltar" update=":formListarCliente"
						onclick="PF('painelAlterarCliente').close(); PF('painelListarCliente').show();"
						type="button" />
					<p:commandButton value="Enviar" id="botao"
						action="#{clienteBean.atualizarCliente}" styleClass="botao"
						update=":formListarCliente"
						oncomplete="PF('painelAlterarCliente').close(); PF('painelListarCliente').show();" />
				</div>
			</h:form>
		</p:panel>

		<!-- Consultar Cliente -->
		<p:panel id="painelConsultarCliente"
			widgetVar="painelConsultarCliente" visible="false" closable="true"
			closeSpeed="0" style="border: none">
			<h:form id="formConsultarCliente">
				<p:panel style="width: 50%;">
					<h2>
						<h:outputText value="#{clienteBean.cliente.nome}" />
					</h2>
					<table border="1" class="tableConsulta" cellpadding="10">
						<tr>
							<td><h:outputText value="Nome: " /></td>
							<td><h:outputText value="#{clienteBean.cliente.nome}" /></td>
						</tr>
						<tr>
							<td><h:outputText value="Data de Nascimento: " /></td>
							<td><h:outputText
									value="#{clienteBean.cliente.dataNasc.time}">
									<f:convertDateTime type="both" pattern="dd/MM/yyyy" />
								</h:outputText></td>
						</tr>
						<tr>
							<td><h:outputText value="Sexo: " /></td>
							<td><h:outputText id="sexoCliIncl"
									value="#{clienteBean.cliente.sexo}" /></td>
						</tr>
						<tr>
							<td><h:outputText value="Login: " /></td>
							<td><h:outputText value="#{clienteBean.cliente.login}" /></td>
						</tr>
						<tr>
							<td><h:outputText value="CPF: " /></td>
							<td><h:outputText value="#{clienteBean.cliente.cpf}" /></td>
						</tr>
						<tr>
							<td><h:outputText value="Telefone: " /></td>
							<td><h:outputText value="#{clienteBean.cliente.telefone}" /></td>
						</tr>
						<tr>
							<td><h:outputText value="Endereço: " /></td>
							<td><h:outputText value="#{clienteBean.cliente.endereco}" /></td>
						</tr>
						<tr>
							<td><h:outputText value="Estado: " /></td>
							<td><h:outputText value="#{clienteBean.cliente.estado}" /></td>
						</tr>
						<tr>
							<td><h:outputText value="Cidade: " /></td>
							<td><h:outputText value="#{clienteBean.cliente.cidade}" /></td>
						</tr>
						<tr>
							<td><h:outputText value="Observação: " /></td>
							<td><h:outputText value="#{clienteBean.cliente.observacao}" /></td>
						</tr>
					</table>

				</p:panel>
				<div class="posicao_botao" align="right">
					<p:commandButton value="Voltar"
						onclick="PF('painelConsultarCliente').close(); PF('painelListarCliente').show();"
						type="button" />
					<p:commandButton value="Alterar" update=":formAlterarCliente"
						oncomplete="PF('painelConsultarCliente').close(); PF('painelAlterarCliente').show();"
						styleClass="botao" />
				</div>
			</h:form>
		</p:panel>
	</h:panelGroup>
</body>
</html>
